// SPDX-License-Identifier: GPL-2.0
/*
 * SLAB ALLOCATOR: GENERAL CACHE
 *
 * (C) 2024.05.01 BuddyZhang1 <buddy.zhang@aliyun.com>
 */
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>

/* PRIVATE DATA */
struct BiscuitOS_data {
	char buffer[16];
};

static int __init BiscuitOS_init(void)
{
	struct BiscuitOS_data *p;

	/* ALLOC OBJECT */
	p = kmalloc(sizeof(struct BiscuitOS_data), GFP_KERNEL);
	if (!p) {
		printk("ERROR: KMALLOC FAILED\n");
		return -ENOMEM;
	}

	/* ACCESS */
	sprintf(p->buffer, "Hello BiscuitOS");
	printk("%s\n", p->buffer);

	/* RECLIAM */
	kfree(p);

	return 0;
}

static void __exit BiscuitOS_exit(void) { }

module_init(BiscuitOS_init);
module_exit(BiscuitOS_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("BiscuitOS <buddy.zhang@aliyun.com>");
MODULE_DESCRIPTION("Linux Dream Motion on BiscuitOS");
